<?php

use Jialeo\LaravelSchemaExtend\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddRelationOldColumnToRepaySummary extends Migration
{
    private $table = 'repay_summaries';

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table($this->table, function (Blueprint $table) {
            $table->string('trans_id', 255)->default('')->comment('旧卡贷关联数据,关联ws_loan.loan_apply.id')->after('current_repay');
            $table->string('loan_channel', 255)->default('')->comment('旧卡贷关联数据,关联ws_loan.loan_apply.loan_channel')->after('trans_id');
            $table->dropUnique('repay_summaries_uid_loan_id_unique'); //删除索引
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        if(Schema::hasTable($this->table)){
            Schema::table($this->table, function (Blueprint $table) {
                $table->dropColumn('trans_id');
                $table->dropColumn('loan_channel');
                $table->unique(['uid','loan_id']);
            });
        }
    }
}
